package Professor;

import java.util.List;
import java.util.Scanner;

public class College_ProfessorService implements College_ProfessorIService {
	private College_ProfessorDAO pdao = new College_ProfessorDAO();
	@Override
	public void insertCollege() {
		
		System.out.println("교수번호 생성 해주세요");
		Scanner sc = new Scanner(System.in);
		College_ProfessorVO p = new College_ProfessorVO();
		System.out.println("비밀번호를 입력해주세요");
		p.setUSER_PW(sc.next());
		System.out.println("이름을 입력해주세요");
		p.setPROF_NAME(sc.next());
		System.out.println("전화번호를 입력해주세요");
		p.setPROF_TEL(sc.next());
		System.out.println("주소를 입력해주세요");
		p.setPROF_ADDR(sc.next());
		System.out.println("사무실위치를 입력해주세요");
		p.setPROF_OFFICE(sc.next());
		System.out.println("담당학과를 입력해주세요");
		p.setDEPT_NO(sc.next());
		System.out.println("담당과목을 입력해주세요");
		p.setSUB_NO(sc.next());
		if(pdao.insertCollege(p))
			System.out.println("정보가 입력되었습니다.");
		else
			System.out.println("다시시도해주세요");
	}
	@Override
	public void readCollege() {
		List<College_ProfessorVO> result = pdao.selectCollege();
		for(int i = 0; i < result.size(); ++i){
			College_ProfessorVO f = result.get(i);
			
		}
		for(College_ProfessorVO p : pdao.selectCollege()){
			
			System.out.print("순번 :" + p.getPROF_TR());
			System.out.print('/');
			System.out.print(" 교수번호 : " + p.getPROF_NO());
			System.out.print('/');
			System.out.print("비밀번호 : " + p.getUSER_PW());
			System.out.print('/');
			System.out.print("이름 :" +p.getPROF_NAME());
			System.out.print('/');
			System.out.print("전화번호 : " + p.getPROF_TEL());
			System.out.print('/');
			System.out.print("주소 : " + p.getPROF_ADDR());
			System.out.print('/');
			System.out.print("사무실 : " + p.getPROF_OFFICE());
			System.out.print('/');
			System.out.print("학과번호 : " + p.getDEPT_NO());
			System.out.print('/');
			System.out.print("과목번호 : " + p.getSUB_NO());
			System.out.println('/');
		
		}
	}
		
	
	@Override
	public void updateCollege() {
		College_ProfessorVO p = new College_ProfessorVO();
		Scanner sc = new Scanner(System.in);
		System.out.println("변경하실 교수번호를 입력해주세요");
		p.setPROF_TR(sc.next());
		System.out.println("변경하실 비밀번호를 입력해주세요");	
		p.setUSER_PW(sc.next());
		System.out.println("변경하실 전화번호를 입력해주세요");
		p.setPROF_TEL(sc.next());
		System.out.println("변경하실 주소를 입력해주세요");
		p.setPROF_ADDR(sc.next());
		System.out.println("변경하실 담당과목을 입력해주세요");
		p.setSUB_NO(sc.next());
		if(pdao.updateCollege(p)){
			System.out.println("수정이 완료되었습니다."); 
		}else{
			System.out.println("잘못된 부분이 있습니다."); 
		}
	}

	@Override
	public void deleteCollege() {
		College_ProfessorVO p = new College_ProfessorVO();
		Scanner sc = new Scanner(System.in);
		System.out.println("지우실 교수 번호를 입력하세요");
		p.setPROF_TR(sc.next());
		if(pdao.deleteCollege(p))
			System.out.println("삭제가 완료 되었습니다.");
		else
			System.out.println("다시 시도해 주십시요");
	}
	@Override
	public void startPage() {
		Scanner sc = new Scanner(System.in);
		while (true) {
		College_ProfessorService p = new College_ProfessorService();

		System.out.println("생성[1]" + " | " + "정보조회[2]" + " | " + "수정[3]" + " | " + "삭제[4]" + " 번호를 입력하세요");
		

			switch (sc.nextInt()) {
			case 1:
				p.insertCollege();break;
			case 2:
				p.readCollege();break;
			case 3:
				p.updateCollege();break;
			case 4:
				p.deleteCollege();break;
			default:
				System.out.println("잘못입력하셧습니다");
			}
			
		}
	}
}